import request from '../../utils/request';

// service-order 管理相关 API

// 更新订单
export const updateOrder = (data) => {
    return request({
        url: '/order/service-order',
        method: 'put',
        data: data,
    });
};

// 创建订单
export const createOrder = (data) => {
    return request({
        url: '/order/service-order',
        method: 'post',
        data: data,
    });
};

// 更新订单状态
export const updateOrderStatus = (orderId, params) => {
    return request({
        url: `/order/service-order/${orderId}/status`,
        method: 'put',
        params: params,
    });
};

// 申请退款
export const refundOrder = (orderId, params) => {
    return request({
        url: `/order/service-order/${orderId}/refund`,
        method: 'put',
        params: params,
    });
};

// 处理退款
export const processRefund = (orderId, params) => {
    return request({
        url: `/order/service-order/${orderId}/process-refund`,
        method: 'put',
        params: params,
    });
};

// 更新支付状态
export const updatePaymentStatus = (orderId, params) => {
    return request({
        url: `/order/service-order/${orderId}/payment-status`,
        method: 'put',
        params: params,
    });
};

// 支付订单
export const payOrder = (orderId, params) => {
    return request({
        url: `/order/service-order/${orderId}/pay`,
        method: 'put',
        params: params,
    });
};

// 完成订单
export const completeOrder = (orderId) => {
    return request({
        url: `/order/service-order/${orderId}/complete`,
        method: 'put',
    });
};

// 取消订单
export const cancelOrder = (orderId, params) => {
    return request({
        url: `/order/service-order/${orderId}/cancel`,
        method: 'put',
        params: params,
    });
};

// 申请退款
export const requestRefund_1 = (orderId, params) => {
    return request({
        url: `/order/service-order/${orderId}/request-refund`,
        method: 'post',
        params: params,
    });
};

// 退款审核
export const auditRefund = (data) => {
    return request({
        url: '/order/service-order/audit-refund',
        method: 'post',
        data: data,
    });
};

// 查询订单详情
export const getOrderById = (id) => {
    return request({
        url: `/order/service-order/${id}`,
        method: 'get',
    });
};

// 分页查询订单
export const getOrderPage = (params) => {
    return request({
        url: '/order/service-order/page',
        method: 'get',
        params: params,
    });
};

// 根据订单号查询订单
export const getOrderByOrderNo = (orderNo) => {
    return request({
        url: `/order/service-order/order-no/${orderNo}`,
        method: 'get',
    });
};

